import 'package:flutter/material.dart';
import 'package:flutter_house_manager/components/notify_item.dart';

class HomeList extends StatefulWidget {
  const HomeList({super.key, required this.list});
  // 社区公告列表
  final List list;

  @override
  _HomeListState createState() => _HomeListState();
}

class _HomeListState extends State<HomeList> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // 社区公告
        getTitleWidget(),
        // 公告列表
        getListBuilder(),
      ],
    );
  }

  Widget getListBuilder() {
    return ListView(
      shrinkWrap: true,
      physics: const NeverScrollableScrollPhysics(),
      children: widget.list.map((item) {
        return NotifyItem(item: item);
      }).toList(),
    );
  }

  //社区公告
  Widget getTitleWidget() {
    return Container(
        padding: const EdgeInsets.symmetric(horizontal: 10),
        child: Column(
          children: [
            //通知
            Row(
              children: [
                Image.asset(
                  'assets/images/notice@2x.png',
                  width: 20,
                  height: 20,
                ),
                const SizedBox(width: 5),
                const Text(
                  '社区',
                  style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
                ),
                const Text(
                  '公告',
                  style: TextStyle(
                      fontSize: 12,
                      color: Colors.orangeAccent,
                      fontWeight: FontWeight.bold),
                )
              ],
            ),
            const SizedBox(height: 10),
            //详情
          ],
        ));
  }
}
